package com.alan.service.impl;

import com.alan.entity.teach;
import com.alan.entity.teacherstudent;
import com.alan.repository.AdminRepository;
import com.alan.repository.impl.AdminRepsitoryImpl;
import com.alan.service.AdminService;

import java.util.List;

public class AdminServiceImpl implements AdminService {
    private AdminRepository adminRepository = new AdminRepsitoryImpl();
    private static int LIMIT = 10;

    @Override
    public List<teacherstudent> findall(int page) {
        int index = (page - 1) * LIMIT;
        return adminRepository.findall(index, LIMIT);
    }

    @Override
    public int getSumpages() {
        int count = adminRepository.counts();
        return (count + 9) / LIMIT;
    }

    @Override
    public List<teach> findallteachers(int page) {
        int index = (page - 1) * LIMIT + 1;
        return adminRepository.findallteacher(index,LIMIT);
    }

    @Override
    public int getteacherpages() {
        int count=adminRepository.teachercounts();
        return (count + 9)/LIMIT;
    }
}
